document.write("<script type='text/javascript' src='/Public/js/layer/layer.js'></script>");
$(function () {
/*    //选择仓库类型
    $('#x').change(function () {
        var type = $(this).find("option:selected").attr('_type');
        if(type == 'Day')
        {
            $('#ri').show()
            $('#miao').hide()
        }else if(type == 'Hour')
        {
            $('#ri').hide()
            $('#miao').show()
        }
        else
        {
            $('#ri').hide()
            $('#miao').hide()
        }
    })*/
    //确认下单
    $('#queren').click(function () {
        if($("#checkbox").is(":checked") == false)
        {
            //alert('请选择协议')
            layer.msg('请选择协议')
            return false
        }
        var url="index.php?g=YunCangChu&m=Time&a=queren"
        //仓库ID
        var StoreID = getParam('cangku');
        //面积规格ID
        var AreaID = getParam('id');
        //存放物品类型
        var GoodsCate=$('#wu').val();
        if(GoodsCate == 0)
        {
            layer.msg('物品列别必选')
            return false
        }
        //SrvStartDate 起租日期
        var SrvStartDate = $('input[_class="times"]').val()
        if($('input[_class="times"]').attr('id') == 'appDate')
        {
            SrvStartDate+=' 00:00'
        }
        if(SrvStartDate == '')
        {
            //alert('请选择起租时间')
            layer.msg('请选择起租时间')
            return false
        }
        //Times 租期
        var Times =  $('#zuqi').val()
        if(Times == '')
        {
            //alert('请填写租期')
            layer.msg('请填写租期')
            return false
        }
        if(Times > 8760)
        {
            //alert('租期不能大于8760')
            layer.msg('租期不能大于8760')
            return false
        }
        //申明价值 Value
        var Value = $('#jiazhi').val()
        if(Value == '')
        {
            Value = 0;
        }
        else if(Value > 100000)
        {
            //alert('申明价值不能超过10万')
            layer.msg('申明价值不能超过10万')
            return false
        }
        //Packs 包装数量
        var Packs = $('#shuliang').val()
        if(Packs == '')
        {
            Packs = 1;
        }else if(Packs > 1000)
        {
            //alert('包装数量不能超过1000')
            layer.msg('包装数量不能超过1000')
            return false
        }
        //存放类型
        var cunfang = $('#cunfang').val()
        if(cunfang == 'item-1')
        {
            var SelfStore = 'TRUE'
        }
        else
        {
            var SelfStore = 'FALSE'
        }
        //提取类型
        var tiqu = $('#tiquleixing').val()
        if(tiqu == 'item-1')
        {
            var tiqu = 'TRUE'
        }
        else
        {
            var tiqu = 'FALSE'
        }
       url+="&StoreID="+StoreID+"&AreaID="+AreaID+"&GoodsCate="+GoodsCate+"&SrvStartDate="+SrvStartDate+"&Times="+Times+"&Value="+Value+"&Packs="+Packs+"&SelfStore="+SelfStore
       if(SelfStore == 'TRUE' && tiqu == 'TRUE')
       {

           url+'&SelfPick='+'TRUE'
           $.get(url,function (rel) {
            if(rel.code == '0')
            {
                location.href="/index.php?g=YunCangChu&m=Time&a=mingxi&id="+rel.url
            }
            else
            {
                alert(rel.msg)
            }
           })
            return false
       }
       if(SelfStore == 'FALSE' )
       {
       //发件人
        var Shper = $('#fajianren').val()
        if(Shper == '')
        {
            //alert('发件人不能为空')
            layer.msg('发件人不能为空')
            return false
        }
        //PickDate1 预约取件时间1
        var PickDate1 = $('#startStartTime').val()
        if(PickDate1 == '')
        {
            //alert('请填写取件起始时间')
            layer.msg('请填写取件起始时间')

            return false
        }
        //PickDate2 预约取件时间2
        var PickDate2 = $('#endtStartTime').val()
        if(PickDate2 == '')
        {
            //alert('请填写取件结束时间')
            layer.msg('请填写取件结束时间')
            return false
        }
        //ShpMobile 联系人手机号 必须填写
        var ShpMobile =$('#ShpMobile').val()
        if(ShpMobile == '')
        {
           // alert('请填写联系电话')
            layer.msg('请填写联系电话')
            return false
        }
        //获取省 市 县id ShpProv  ShpCity   ShpDistrict
        var ShpProv = $('#city1').val()
        var ShpCity = $('#city2').val()
        var ShpDistrict = $('#city3').val()
        if(ShpProv == 0 || ShpCity==0 || ShpDistrict==0)
        {
            //alert('请选择发件地区')
            layer.msg('请选择发件地区')
            return false
        }
        //发件地址 ShpAddr
        var ShpAddr = $('#ShpAddr').val()
        if(ShpAddr == '')
        {
            //alert('请输入详细地址')
            layer.msg('请输入详细地址')
            return false
        }
       }
        //提取类型
        var tiquleixing = $('#tiquleixing').val()
        url+='&PickDate1='+PickDate1+"&PickDate2="+PickDate2+"&ShpProv="+ShpProv+"&ShpCity="+ShpCity+"&ShpDistrict="+ShpDistrict+'&Shper='+Shper+"&ShpMobile="+ShpMobile+"&ShpAddr="+ShpAddr+"&SelfPick="+SelfPick
        if(tiquleixing == 'item-1')
        {
            var SelfPick = 'TRUE'
            $.get(url,function (rel) {
                if(rel.code == '0')
                {
                    //alert(rel.url)
                    location.href="/index.php?g=YunCangChu&m=Time&a=mingxi&id="+rel.url
                }
                else
                {
                    alert(rel.msg)
                }
            })
            return false
        }
        else
        {
            var SelfPick = 'FALSE'
            //收件人 Consignee
            var Consignee = $('#shoujianren').val()
            if(Consignee == '')
            {
                //alert('请输入收件人')
                layer.msg('请输入收件人')
                return false
            }
            //ConsMobile 收件人手机号
            var ConsMobile =$('#lianxidianhua').val()
            if(ConsMobile == '')
            {
               // alert('请输入收件人手机号')
                layer.msg('请输入收件人手机号')
                return false
            }
            //获取收件省 市 县id ConsProv  ConsCity   ConsDistrict
            var ConsProv = $('#city4').val()
            var ConsCity = $('#city5').val()
            var ConsDistrict = $('#city6').val()
            if(ConsProv == 0 || ConsCity==0 || ConsDistrict==0)
            {
                //alert('请选择发件地区')
                layer.msg('请选择发件地区')
                return false
            }
            //收件人详细地址 ConsAddr
            var ConsAddr = $('#ConsAddr').val()
            if(ConsAddr == '')
            {
                //alert('请填写收件人详细地址')
                layer.msg('请填写收件人详细地址')
                return false
            }
            //起始派送时间 DelivDate1 DelivDate2
            var DelivDate1 = $('#startDeliveryTime').val()
            if(DelivDate1 == '')
            {
                //alert('请选择派送开始时间')
                layer.msg('请选择派送开始时间')
                return false
            }

            //结束派送时间
            var DelivDate2 = $('#endtDeliveryTime').val()
            if(DelivDate2 == '')
            {
                //alert('请选择派送结束时间')
                layer.msg('请选择派送结束时间')
                return false
            }
            url+="&DelivDate1="+DelivDate1+"&DelivDate2="+DelivDate2+"&ConsProv="+ConsProv+"&ConsCity="+ConsCity+"&ConsDistrict="+ConsDistrict+"&Consignee="+Consignee+"&ConsMobile="+ConsMobile+"&ConsAddr="+ConsAddr+"&SelfPick="+SelfPick;
            $.get(url,function (rel) {
                if(rel.code == '0')
                {
                    location.href="/index.php?g=YunCangChu&m=Time&a=mingxi&id="+rel.url
                    //alert(rel.url)
                }
                else
                {
                    alert(rel.msg)
                }
            })
            return false
        }
    })
})
/**
 * 获取指定的URL参数值
 * URL:http://www.quwan.com/index?name=tyler
 * 参数：paramName URL参数
 * 调用方法:getParam("name")
 * 返回值:tyler
 */
function getParam(paramName) {
    paramValue = "", isFound = !1;
    if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
        arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&"), i = 0;
        while (i < arrSource.length && !isFound) arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++
    }
    return paramValue == "" && (paramValue = null), paramValue
}

